/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Visao;

/**
 *
* @author andreus & gabriel
 */
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class runBanner implements Runnable {

    private JLabel banner;
    private int alterar = 0;

    public runBanner(JLabel banner) {
        this.banner = banner;
    }

    @Override
    public void run() {
        ArrayList<ImageIcon> Images = new ArrayList<>();
        Images.add(new ImageIcon(getClass().getResource("imagem1.jpg")));
        Images.add(new ImageIcon(getClass().getResource("imagem2.jpg")));
        Images.add(new ImageIcon(getClass().getResource("imagem3.jpg")));
        Images.add(new ImageIcon(getClass().getResource("imagem4.jpg")));

        try {
            while (true) {
                alterar = (alterar) % Images.size(); //Altera as imagens
                Thread.sleep(2000);
                banner.setIcon(Images.get(alterar));
                alterar++;
            }
        } catch (Exception e) {
            System.out.println("Interrupted");
        }
    }
}
